import Vue from "vue";
import Teleport from "./Teleport.vue";
const TeleportConstructor = Vue.extend(Teleport);
export default function (render, position) {
  TeleportConstructor.prototype.close = function () {
    if (this.$el && this.$el.parentNode) {
      this.$el.parentNode.removeChild(this.$el);
    }
    this.$destroy();
  };
  const teleportInstance = new TeleportConstructor({
    propsData: { render, position },
  });
  teleportInstance.$mount();
  document.body.appendChild(teleportInstance.$el);
  return teleportInstance;
}
